class ActsAsDebatableMigration < ActiveRecord::Migration
  def self.up

    create_table :comments do |t|

      t.references :commentable, :polymorphic => true

      t.text :content
      
      #this is for anonymous users
      t.string :author 
      t.string :author_email
      t.string :author_url
      t.string :user_ip
      t.string :user_agent
      
      #this is for logged users
      t.integer :user_id
      
      #we use ancestry!
      t.string :ancestry
      t.integer :ancestry_depth, :default => 0

      #for akismet
      t.boolean :spam

      #if user is not registered site owner has to approve the comment
      t.boolean :approved

      t.timestamps
    end
    add_index :comments, :ancestry
  end

  def self.down
    drop_table :comments
  end
end
